<?php include("includes/session.php"); ?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $lang['PAGE_TITLE_PROFILE']; ?></title>
<?php include("header.php"); ?>
	<center>
	<table cellpadding="0" cellspacing="0" width="93%">
	<tr>
		<td align="left">
			<?php 
			if(!$session->logged_in && !isset($_GET['user']))
			{
				echo "<br /><center><h3>You must be logged in to view your profile.</h3></center>";
			}
			else
			{
				unset($profile);
				if(isset($_GET['user']))
				{
					$profile = $database->getUserInfo($_GET['user']);
				}
				else
				{
					$profile = $session->userinfo;
				}
			?>
			<table cellpadding="10" cellspacing="0" width="100%">
			<tr>
				<td></td>
			</tr>
			<tr>
				<td valign="top">
					<table cellpadding="0" cellspacing="0" width="232px">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td><center><font size="+1"><b><?php echo $profile['username']; ?></b></font></center></td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0" width="232px">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td>
						<img width="200" height="200" border="1" src="<?php if($profile['profilePic']==''){ echo DEFAULT_PROFILE_PIC; }else{ echo $profile['profilePic']; } ?>" />
						<?php
						if($profile['username']!=$session->username && $session->userlevel>0)
						{
						?>
						<br /><br /><center><a href="messages.php?send=<?php echo $profile['username']; ?>" title="Send A Message">Message</a></center>
						<?php
						}
						?>
						</td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0" width="232px">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td>
							<center>
							<table cellpadding="3" cellspacing="0">
							<tr>
								<td colspan="2"><center>
								<?	$retval = $database->query("SELECT * FROM ".TBL_ACTIVE_USERS." WHERE username='".$profile['username']."'");
									if(mysql_num_rows($retval)>0){ echo "<b><font color=\"#0f8100\">Online!</font></b>"; } ?></center>
								</td>
							</tr>
							<tr>
								<td align="right"><b><?php echo $lang['PROFILE_NAME']; ?></b></td>
								<td align="left"><? echo $profile['fname']." ".$profile['lname']; ?></td>
							</tr>
							<tr>
								<td align="right"><b><?php echo $lang['PROFILE_GENDER']; ?></b></td>
								<td align="left"><? echo $profile['gender']; ?></td>
							</tr>
							<tr>
								<td align="right"><b><?php echo $lang['PROFILE_COUNTRY']; ?></b></td>
								<td align="left">
									<?
									$result = $database->query("SELECT country FROM ".TBL_COUNTRIES." WHERE code='".$profile['country']."'");
									$row = mysql_fetch_array($result);
									echo $row['country'];
									?>
								</td>
							</tr>
							<tr>
								<td align="right"><b><?php echo $lang['PROFILE_LOCATION']; ?></b></td>
								<td align="left"><? echo $profile['city'].", ".$profile['state']; ?></td>
							</tr>
							<tr>
								<td align="right"><b>Last On:</b></td>
								<td align="left"><? echo date('F j, Y',$profile['timestamp']); ?></td>
							</tr>
							</table>
							</center>
						</td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<?php
					if($profile['email']!='' && $profile['displayEmail']==1 || $profile['aim']!='' || $profile['msn']!='' || $profile['yahoo']!='' || $profile['icq']!='0' && $profile['icq']!='' || $profile['skype']!='')
					{
					?>
					<table cellpadding="0" cellspacing="0" width="232px">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td>
							<div style="width:202px;overflow:auto;">
							<font size="-2">
							<center>
							<table cellpadding="3" cellspacing="0">
							<?php
							if($profile['email']!='' && $profile['displayEmail']==1)
							{
							?>
							<tr>
								<td align="right"><b><?php echo $lang['PROFILE_EMAIL']; ?></b></td>
								<td align="left"><? echo $profile['email']; ?></td>
							</tr>
							<?php
							}
							if($profile['aim']!='')
							{
							?>
							<tr>
								<td align="right"><b>AIM:</b></td>
								<td align="left"><? echo $profile['aim']; ?></td>
							</tr>
							<?php
							}
							if($profile['msn']!='')
							{
							?>
							<tr>
								<td align="right"><b>MSN:</b></td>
								<td align="left"><? echo $profile['msn']; ?></td>
							</tr>
							<?php
							}
							if($profile['yahoo']!='')
							{
							?>
							<tr>
								<td align="right"><b>Yahoo:</b></td>
								<td align="left"><? echo $profile['yahoo']; ?></td>
							</tr>
							<?php
							}
							if($profile['icq']!='0' && $profile['icq']!='')
							{
							?>
							<tr>
								<td align="right"><b>ICQ:</b></td>
								<td align="left"><? if($profile['icq']!="0"){ echo $profile['icq']; } ?></td>
							</tr>
							<?php
							}
							if($profile['skype']!='' && $profile['skype']!='0')
							{
							?>
							<tr>
								<td align="right"><b>Skype:</b></td>
								<td align="left"><? echo $profile['skype']; ?></td>
							</tr>
							<?php
							}
							if($profile['jabber']!='')
							{
							?>
							<tr>
								<td colspan="2" align="left"><b>Jabber/Gtalk IM:</b></td>
							</tr>
							<tr>
								<td colspan="2" align="right"><? echo $profile['jabber']; ?></td>
							</tr>
							<?php
							}
							?>
							</table>
							</center>
							</font>
							</div>
						</td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<?php
					}
					?>
				</td>
				<td valign="top">
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td><b><?php echo $lang['PROFILE_ABOUTME']; ?></b> <?php echo $profile['thoughts']; ?></td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td><b><?php echo $lang['PROFILE_SKILLS']; ?></b> <?php echo $profile['skills']; ?></td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td><b><?php echo $lang['PROFILE_CONTRIB']; ?></b> <?php echo $profile['provisions']; ?></td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0" width="100%">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td>
						<center><font size="+1"><b><?php echo $lang['PROFILE_RESOURCES']; ?></b></font></center>
						<?php
						displayUserResources($profile['username']);
						?>
						</td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0" width="100%">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td>
						<center><font size="+1"><b><?php echo $lang['PROFILE_PROJECTS']; ?></b></font></center>
						<?php
						displayUserProjects($profile['username']);
						?>
						</td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0" width="100%">
					<tr>
						<td class="topLeft"></td><td bgcolor="#dadada"></td><td class="topRight"></td>
					</tr>
					<tr bgcolor="#dadada">
						<td></td><td>
						<center><font size="+1"><b>Links</b></font></center>
						<?php
						displayUserLinks($profile['username']);
						?>
						</td><td></td>
					</tr>
					<tr>
						<td class="bottomLeft"></td><td bgcolor="#dadada"></td><td class="bottomRight"></td>
					</tr>
					</table>
				</td>
			</tr>
			</table>
			<?php 
			}
			?>
		</td>
	</tr>
	</table>
	</center>
<?php include("footer.php"); ?>